package ZorkObjects;

import java.util.ArrayList;
import java.util.HashMap;

public class Creature extends ZorkObject
{
    private ArrayList<String> vulnerabilities;
    private Attack attack;

    public Creature(HashMap configMap) 
    {
        super(configMap);
        attack = new Attack((HashMap)configMap.remove("attack"));
        vulnerabilities = new ArrayList<String>();

        Object vulnerabilityContainer = configMap.remove("vulnerability");
        if(vulnerabilityContainer instanceof String)
        {
            vulnerabilities.add((String)vulnerabilityContainer);
        }
        else if(vulnerabilityContainer instanceof ArrayList)
        {
            for(String vulnerability : (ArrayList<String>)vulnerabilityContainer)
            {
                vulnerabilities.add(vulnerability);
            }
        }
        else {
            System.out.println("this should never happen creature");
        }

    }

	public ArrayList<String> getVulnerabilities() {
		return vulnerabilities;
	}

	public Attack getAttack() {
		return attack;
	}

    public String toString() {
        String base = super.toString();

        base += "vulnerability = " + vulnerabilities.toString();
        base += "\n";
        base += "attack = " + attack.toString();

        return base;
    }
}
